Machine Learning with Scala Quick Start Guide by Md. Rezaul Karim
Author:Md. Rezaul Karim [Md. Rezaul Karim]
Language: eng
Format: epub
Tags: COM037000 - COMPUTERS / Machine Theory, COM018000 - COMPUTERS / Data Processing, COM062000 - COMPUTERS / Data Modeling and Design
Publisher: Packt
Published: 2019-04-30T21:09:52+00:00
However, based on the preceding prediction DataFrame, it is really difficult to guess the classification's accuracy. But in the second step, the evaluation is done using BinaryClassificationEvaluator as follows:
val accuracy = evaluator.evaluate(predictions)
println("Classification accuracy: " + accuracy)
This will provide an output with an accuracy value:
Accuracy: 0.8441663599558337
So, we get about 84% classification accuracy from our binary classification model. Just like with SVM and LR, we will observe the area under the precision-recall curve and the area under the receiver operating characteristic (ROC) curve based on the following RDD, which contains the raw scores on the test set:
val predictionAndLabels = predictions
.select("prediction", "label")
.rdd.map(x => (x(0).asInstanceOf[Double], x(1)
.asInstanceOf[Double]))
The preceding RDD can be used for computing the previously mentioned two performance metrics:
val metrics = new BinaryClassificationMetrics(predictionAndLabels)
println("Area under the precision-recall curve: " + metrics.areaUnderPR)
println("Area under the receiver operating characteristic (ROC) curve: " + metrics.areaUnderROC)
In this case, the evaluation returns 84% accuracy but only 67% precision, which is much better than that of SVM and LR:
Area under the precision-recall curve: 0.6665988000794282
Area under the receiver operating characteristic (ROC) curve: 0.8441663599558337
Then, we calculate some more metrics, for example, false and true positive, and false and true negative, as these predictions are also useful to evaluate the model's performance:
val TC = predDF.count() //Total count
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Computer Vision & Pattern Recognition | Expert Systems |
Intelligence & Semantics | Machine Theory |
Natural Language Processing | Neural Networks |
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(7879)
Hadoop in Practice by Alex Holmes(5673)
Jquery UI in Action : Master the concepts Of Jquery UI: A Step By Step Approach by ANMOL GOYAL(5527)
Life 3.0: Being Human in the Age of Artificial Intelligence by Tegmark Max(4536)
Functional Programming in JavaScript by Mantyla Dan(3733)
The Age of Surveillance Capitalism by Shoshana Zuboff(3445)
Big Data Analysis with Python by Ivan Marin(3176)
Blockchain Basics by Daniel Drescher(2907)
The Rosie Effect by Graeme Simsion(2730)
Test-Driven Development with Java by Alan Mellor(2712)
WordPress Plugin Development Cookbook by Yannick Lefebvre(2650)
Hands-On Machine Learning for Algorithmic Trading by Stefan Jansen(2568)
Data Augmentation with Python by Duc Haba(2565)
Applied Predictive Modeling by Max Kuhn & Kjell Johnson(2500)
Dawn of the New Everything by Jaron Lanier(2450)
Principles of Data Fabric by Sonia Mezzetta(2373)
The Infinite Retina by Robert Scoble Irena Cronin(2352)
The Art Of Deception by Kevin Mitnick(2313)
Rapid Viz: A New Method for the Rapid Visualization of Ideas by Kurt Hanks & Larry Belliston(2214)